<template>
  <div class="result">
    <div class="header_body">
      <header-nav :leftArrow="true" titelText="行政许可审批"></header-nav>

      <div class="result-content">
        <div class="pdBox">
          <div class="pdBox-title">
            <span style="color: #ee0a24; margin-right: 2px">*</span>审批结果
          </div>
          <van-radio-group style="padding-left: 7px" v-model="resultForm.nodeStatus" direction="horizontal">
            <van-radio :name="2" style="margin-right: 52px">同意</van-radio>
            <van-radio :name="3">不同意</van-radio>
          </van-radio-group>
        </div>
        <div class="line10"></div>

        <div style="padding: 16px 16px 0 16px">
          <span v-if="resultForm.nodeStatus == 3" style="color: #ee0a24; margin-right: 2px">*</span>
          <span>审批意见</span>
        </div>
        <van-field v-model="resultForm.approveOpinions" required type="textarea" rows="2" autosize maxlength="128"
          placeholder="请输入审批意见" />

        <div class="submitBtn2">
          <van-button block type="primary" class="btn-left" @click="submit()">
            提交
          </van-button>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup>
import { showSuccessToast, showFailToast, showNotify } from 'vant'
const { useApprove } = $globalStore
const router = useRouter()
const route = useRoute()
const id = ref(route.query.id)
const caseId = ref(route.query.caseId)
const fromType = ref(route.query.fromType)

const resultForm = reactive({
  id: id.value,
  caseId: caseId.value,
  nodeStatus: 2,
  approveOpinions: '',
})

const submit = async () => {
  if (resultForm.nodeStatus == 3 && resultForm.approveOpinions == '') {
    return showNotify({ type: 'danger', message: '请输入审批意见' })
  }
  const res = await useApprove.approveTask(resultForm)
  if (res.code == 0) {
    showSuccessToast('审核成功')
    if (fromType.value == 1) {
      router.push({ name: 'approveList' })
    } else {
      router.go(-1)
    }
  } else {
    showFailToast(res.message)
  }
}

onMounted(async () => { })
</script>
<style lang="scss" scoped>
.result {
  width: 100%;
  height: 100%;
  overflow-y: hidden;

  .result-content {
    width: 100%;
    height: 100%;
    margin-top: 46px;

    .title {
      padding: 16px;
      font-size: 16px;
      font-weight: 500;
      letter-spacing: 0px;
      line-height: 24px;
      color: #2b2b2b;
      border-bottom: 1px solid #f0f0f0;
    }

    .wsBox {
      padding: 16px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      border-bottom: 1px solid #f5f5f5;

      .text {
        display: flex;
        align-items: center;

        >img {
          width: 36px;
          height: 36px;
          margin-right: 12px;
        }

        >div {
          font-size: 15px;
          font-weight: 500;
          letter-spacing: 0px;
          line-height: 22px;
          color: #2b2b2b;
        }
      }
    }

    .pdBox {
      padding: 16px;
      border-bottom: 1px solid #f5f5f5;

      .pdBox-title {
        margin-bottom: 16px;
        font-size: 16px;
        font-weight: 400;
        letter-spacing: 0px;
        line-height: 24px;
        color: #4d4d4d;
      }
    }
  }
}

.line10 {
  width: 100%;
  height: 10px;
  background-color: #f7f7f7;
}

.result .van-field__control {
  padding: 0 !important;
}
</style>
